package com.xxtx.trade.timer;


import com.xxtx.trade.sysUser.service.TradeSysRoleService;
import com.xxtx.trade.sysUser.service.TradeSysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


/**
 * 定时轮训:
 */
@Component
public class UpdateSimDataTimer {
    @Autowired
    private TradeSysRoleService tradeSysRoleService;

    @Autowired
    private TradeSysUserService tradeSysUserService;

    /**
     *  每天更新一次昨天得点击人数,5点50
     *
     */
    @Scheduled(cron = "0 50 5 * * ?")
    public void lunXunThreads(){
        tradeSysRoleService.lunxunSimData();
    }


    /**
     * 每天更新一次不同链接的点击人数,5点30
     * */
    @Scheduled(cron = "0 30 5 * * ?")
    public void autoUpdateDouYingCountCondition(){tradeSysUserService.tidyCountDataCondition();}


    /**
     * 设置定时任务，删除90天（三个月）之前的数据,5点05
     * */
    @Scheduled(cron = "0 05 5 * * ?")
    public void deleteExpiredInfo(){tradeSysUserService.deleteExpiredInfo();}

    /**
     * 每天删除一次七天前的 redis set，5点40
     * */
    @Scheduled(cron = "0 40 5 * * ?")
    public void deleteExpiredRedis(){tradeSysUserService.deleteExpiredRedis();}

    @Scheduled(cron = "0 15 5 * * ?")
    public void deleteExpiredUrlLog(){tradeSysUserService.deleteExpiredUrlLog();}

    @Scheduled(cron = "0 */2 * * * *") // 每隔两分钟分钟执行一次，每次取出3000条数据插入数据库
    public void handleInsertData(){tradeSysUserService.handleInsertData();}
//    public void handleInsertData(){}

}
